﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using TrackingSim.Filtering;
using TrackingSim.Filtering.Measurements;

namespace TrackingSim.GameSystem
{
    class Plane : Player
    {
        Radar radar;
        Tracker tracker;
        bool m_enable_radar;
        bool m_enable_tracker;
        double m_last_meas_time;

        public Plane( Vector3 position, Vector3 forward, Vector3 up) :base( position, forward, up)
        {
            radar = new Radar(this);
            tracker = new Tracker(this);
            m_enable_radar = false;
            m_enable_tracker = false;
            m_last_meas_time = 0.0;
        }

        public Tracker Tracker
        {
            get { return tracker; }
        }

        public bool EnableRadar
        {
            get { return m_enable_radar; }
            set { m_enable_radar = value; }
        }

        public bool EnableTracker
        {
            get { return m_enable_tracker; }
            set { m_enable_tracker = value; }
        }

        public void run_se(Player p, double time)
        {
            Rcycz radar_meas = new Rcycz();
            Razel radar_meas_razel = new Razel();

            if (time > m_last_meas_time + 1.0)
            {
                if (EnableRadar)
                {
                    //radar_meas = radar.measure_rcycz(p, time);
                    radar_meas_razel = radar.measure_razel(p, time);
                }

                if (EnableTracker)
                {
                    //tracker.update(p, radar_meas);
                    tracker.update(p, radar_meas_razel);
                }

                m_last_meas_time = time;
            }
        }

        public void print_logged_data()
        {
            tracker.print_data();
        }
    }
}
